import request from '@/utils/http'
import { useAppStore } from '@/store'

const baseURL = import.meta.env.VITE_SLOTS_API
const PATH = '/casino/portal'
const CASINO = '/casino'
const headers = () => {
	const appStore = useAppStore()
	return {
		sRegion: appStore.region || 1,
		sLanguage: appStore.lang || 'en'
	}
}

export function casinoLiveWins(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: CASINO + `/ranking/liveWins`,
		method: 'post',
		data
	})
}

export function bannersReq() {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/banner/list',
		method: 'get'
	})
}

// 推荐
export function casinoRecommendsReq(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/recommendList',
		method: 'post',
		data
	})
}

// Game All 收藏
export function casinoCollectionsReq(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/favorite',
		method: 'post',
		data
	})
}

// Game All 全部
export function casinoAllGameReq(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/allGameList',
		method: 'post',
		data
	})
}

// Game All 推广
export function casinoPromosReq(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/promotionGameList',
		method: 'post',
		data
	})
}

// Game All 游戏分类
export function casinoGameTypeReq(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/gameTypeList',
		method: 'post',
		data
	})
}

// Game 进入游戏二级页面
export function gameDetailReq(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/searchEntrance',
		method: 'post',
		params
	})
}

// 跳转游戏大厅
export function casinoGoinGame(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/getLuaunchURI',
		method: 'post',
		data
	})
}

// 收藏 && 取消收藏
export function casinoCollectGame(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: params.action ? PATH + '/favorite/delete' : PATH + '/favorite/add',
		method: 'post',
		data: {
			eid: params.eid
		}
	})
}

export function casinoLiveBigReq(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: CASINO + '/ranking/livebigwins',
		method: 'get',
		params
	})
}

// export function goinGame(id, params) {
//   return request({
//     headers: headers(),
//     baseURL,
//     url: PATH + '/goinGame/' + id,
//     method: 'get',
//     params
//   })
// }

export function getCasinoStatistic(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/statistics/list',
		method: 'post',
		params
	})
}

export function getRecentGames(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/statistics/searchRecentGames',
		method: 'post',
		params
	})
}

// export function getCurrentGameData(id) {
//   return request({
//     headers: headers(),
//     baseURL,
//     url: PATH + `/betRecord/gamePage/${id}`,
//     method: 'get'
//   })
// }

export function getCasinoRecordList(data: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + `/games/searchOrderFe`,
		method: 'post',
		data
	})
}

export function getCasinoOrderList(params: object, data = {}) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + `/games/searchOrderList`,
		method: 'post',
		params,
		data
	})
}

// export function getGameStatus(id) {
//   return request({
//     headers: headers(),
//     baseURL,
//     url: PATH + `/gameStatus/${id}`,
//     method: 'get'
//   })
// }

// 供应商列表
export function getCasinoProvidersData() {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + `/games/providers`,
		method: 'get'
	})
}

export function getGameFavoriteState(params: any) {
	return request({
		headers: headers(),
		baseURL,
		url: PATH + '/games/checkIfFavorite',
		method: 'post',
		params
	})
}
